package demo3;

import javax.swing.tree.TreeNode;

/**
 * Created with IntelliJ IDEA.
 * Description:时间复杂度：O(N)
 * User: liangyuanzhang
 * Date: 2025-4-20
 * Time: 11:10
 */
/*求树的高度
左树的高度 和 右树的高度的最大值+1
 */
public class Test {

    public int getHeight(TreeNode root){
        if (root == null)
            return 0;
/*        int leftHeight = getHeight(root.left);
        int rightHeight = getHeight(root.right);*/

        return Math.max(getHeight(root.left),getHeight(root.right))+1;
    }
}
